home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12264 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.netins.net!trg1
  2. From: hhowe@trgnet.com (Harold Howe)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Object constuction in function call.
  5. Date: Tue, 19 Mar 96 02:15:18 GMT
  6. Organization: Technology Resource Group
  7. Message-ID: <4il8ln$2vi@insosf1.netins.net>
  8. References: <4icmqh$8g6@insosf1.netins.net> <4ie16n$pc1@sam.inforamp.net>
  9. NNTP-Posting-Host: desm-22-13.dialup.netins.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #3
  11.  
  12.  
  13. >The TCorners that you declare in main() are destroyed when you exit main.  
  14. >Thus at the end of your program you have 0 objects.  Here's a procedure look 
  15. >at what is happening.
  16. >
  17. >int main(void)
  18. >{
  19. >    construct TCorners
  20. >    display TCorners
  21. >    construct TCorners
  22. >    display TCorners
  23. >    construct TCorners
  24. >    display TCorners
  25. >    destroy TCorners
  26. >    destroy TCorners
  27. >    destroy TCorners
  28. >};
  29. >
  30. >when the TCorners lose scope, then the destroy themselves.
  31. >
  32. >Agrivar
  33.  
  34. Thank you for responding.  To all who read my post, I apologize for a huge 
  35. ambiguity on my part.  I meant to ask how many objects exist just before main 
  36. terminates.  In other words does the object that was created in the call to 
  37. display_coordinates exist when display_coordinates returns back to main?  
  38. According to Agrivar's followup, they exist until main ends, and are not 
  39. destroyed when display_coordinates returns.
  40.  
  41. >>int main(void)
  42. >>  {
  43. >>  display_coordinates(TCorners(1,1,20,10));
  44. >>  display_coordinates(TCorners(1,5,25,15));
  45. >>  display_coordinates(TCorners(2,5,20,10));
  46. >>  }
  47.  
  48. Harold Howe
  49. hhowe@trgnet.com
  50.